<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition>
	<h:panelGroup rendered="#{not empty jogadorBean.jogadores}">
		<h2>Lista de Jogadores</h2>
		
		<h:dataTable id="tabela" value="#{jogadorBean.jogadores}" var="jogador"
		    styleClass="dados" rowClasses="par, impar">
		    <h:column>
		    	<f:facet name="header">ID</f:facet>
		    	#{jogador.id}
		    </h:column>
		    <h:column>
		    	<f:facet name="header">Nome</f:facet>
		    	#{jogador.nome}
		    </h:column>
		    <h:column>
		    	<f:facet name="header">Posição</f:facet>
		    	#{jogador.posicao}
		    </h:column>
			<h:column>
				<f:facet name="header">Data de Nascimento</f:facet>
				<h:outputText value="#{jogador.dataDeNascimento.time}">
					<f:convertDateTime pattern="dd/MM/yyyy" />
				</h:outputText>
			</h:column>
			<h:column>
				<f:facet name="header">Time</f:facet>
				#{jogador.time.nome}
			</h:column>
			<h:column>
				<f:facet name="header">Alterar</f:facet>
				<f:ajax event="click" render="@form" listener="#{jogadorBean.preparaAlteracao}">
					<h:commandLink>
						<f:param name="id" value="#{jogador.id}" />
						Alterar
					</h:commandLink>
				</f:ajax>
			</h:column>
			<h:column>
				<f:facet name="header">Remover</f:facet>
				<f:ajax event="click" render="@form" listener="#{jogadorBean.remove}">
					<h:commandLink>
						<f:param name="id" value="#{jogador.id}">
							Remover
						</f:param>
					</h:commandLink>
				</f:ajax>
			</h:column>
		</h:dataTable>
	</h:panelGroup>
</ui:composition> 
</html>